from django.shortcuts import render, redirect


# Create your views here.
def login(request):
    # 如果是POST提交数据
    error = {}
    if request.method == 'POST':
        email = request.POST.get("email")
        if not email:
            error['email'] = "邮箱不能为空"
        password = request.POST.get('password')
        if not password:
            error['password'] = "密码不能为空"
        if email == 'lxgzhw001@163.com' and password == 'lxgzhw001':
            return redirect('/')
        else:
            if email and password:
                error['msg'] = '用户名或密码错误'
        return render(request, 'user/login.html', {'error': error})
    return render(request, 'user/login.html')
